<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>外采购最新推荐</title>
<body class="withvernav">
<div class="bodywrapper">
	<div class="centercontent tables">
		<div class="pageheader notab">
			<h1 class="pagetitle">外采购最新推荐</h1>
			<span class="pagedesc"></span>
		</div>
		<!--pageheader-->
		<div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
		<div id="contentwrapper" class="contentwrapper">
			<!--搜索栏-->
			<form class="stdform stdform2" method="get" action="/welcome/ajaxbutton">
				<div class="tableoptions">
					<input type="hidden" name="op" value="showMoreRecommend"/>
					商品编号: <input type="text" name="other" id="other" class="width200" placeholder="请输入商品编号" value="{{$other}}" />
					&nbsp;&nbsp;
                    <select class="selectCss2" name="status" id="status">
                    <option value="">请选择</option>
                    <option value="1" {{if $status==1}} selected{{/if}}> 已上架</option>
                    <option value="3" {{if $status==3}} selected{{/if}}> 未上架</option>
                  </select>
					&nbsp;&nbsp;
					类型：
					<select class="selectCss2" name="type" id="type">
						<option value="">请选择</option>
						<option value="1" {{if $type==1}} selected{{/if}}> 外采购商品</option>
						<option value="3" {{if $type==3}} selected{{/if}}> 新品开发</option>
						<option value="2" {{if $type==2}} selected{{/if}}> 在售商品</option>
					</select>
					<button class="btn btn_orange btn_search radius50">Search</button>
				</div>
			</form>
			<!--搜索栏结束-->
			<table cellpadding="0" cellspacing="0" border="0" class="stdtable">
				<thead>
				<tr>
					<th class="head0">商品编号</th>
					<th class="head1">类型</th>
					<th class="head1">商品名称</th>
					<th class="head0">推荐人</th>
					<th class="head1">操作</th>
				</tr>
				</thead>
				<tbody>
				{{foreach from=$recommendlist item=li key=key}}
				<tr>
					<td>{{$li.sku}}</td>
					<td>  {{if $li.external_buy==1}} 
                                        外采购开发
						  {{elseif $li.external_buy==2}}
										新品开发
                                        {{else}}
                                        在售产品
                                        {{/if}}</td>
					<td>{{$li.p_parent_name}}
						{{if $li.linkUrl}}
							&nbsp;
							<a href="{{$li.linkUrl}}" target="_blank"><img src="/fuman/images/bj.jpg" /> </a>
						{{/if}}
					</td>
					<td>{{$li.protector}}</td>
					<td class="center">
						{{if $li.return_flag eq 1}}
						{{if $li.cancel_flag eq 1}}
						<span><a href="{{$li.cancel_reason}}" title="点击可以进入链接地址" style="color:red;">已上架</a></span>
						{{/if}}
						{{if $li.cancel_flag eq 2}}
						<span style="color:red;" title="取消原因：{{$li.cancel_reason}}">已取消上架</span>
						{{/if}}
						{{if $li.cancel_flag eq 0}}
						<a href="javascript:void(0);" onClick="sureAdd({{$li.id}},1,1,{{$li.external_buy}});">确认上架</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:void(0);" onClick="sureAdd({{$li.id}},2,0,{{$li.external_buy}});">取消上架</a>
						{{/if}}
						{{else}}
						<a href="javascript:void(0);" onClick="sureAdd({{$li.id}},1,1,{{$li.external_buy}});">确认上架</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:void(0);" onClick="sureAdd({{$li.id}},2,0,{{$li.external_buy}});">取消上架</a>
						{{/if}}
					</td>
				</tr>
				{{/foreach}}
				</tbody>

			</table>
			<div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
			<br />
			<br />
		</div>
	</div>
	<!--bodywrapper-->
	<!-- 模态框（Modal）交运内容 -->
	<form action="/externalBuy/doRecommendGoods" enctype="multipart/form-data" method="post" name="dorecommendattributeform" id="dorecommendattributeform" target="_blank" style="font-size: 14px;font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial, sans-serif;line-height: 21px;color: #666;">
		<div class="modal" id="dorecommendform" tabindex="-1" role="dialog" aria-labelledby="sexpressform" aria-hidden="true" style="margin-top: 60px;padding-top:60px;">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
						        aria-hidden="true" onClick="javascript:$('#dorecommendform').hide();">× </button>
						<h4 class="modal-title"><span id="addsure" style="font-size:18px;">确认上架</span></h4>
					</div>
					<div class="modal-body">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td align="left" width="20%"><span id="showname">上架地址</span></td>
								<td align="left" width="80%">
                                <span id="settext">
                                    <input type="text" value="" name="address" id="address" />
                                </span>
								</td>
							</tr>
						</table>
						<div class="modal-footer">
							<button type="button" class="btn btn-default"
							        data-dismiss="modal" style="display:none"> 关闭 </button>
							<input type="hidden" name="flag" id="flag" value="">
							<input type="hidden" name="extIds" id="extIds" value="">
                            <input type="hidden" name="types" id="types" value="">
							<button type="button" class="btn btn-primary"  onclick="sureAdd(0,3,9)">保存</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal-dialog -->
			</div>
		</div>
	</form>
	<!-- /.modal -->
<script type="text/javascript">
	//确认上架
	function sureAdd(id,add_flag,iscancel,types) {
		if(add_flag == 1){
			$("#addsure").text("确认上架");
			$("#showname").text("上架链接地址");
			$("#settext").html('<input type="text" value="" name="address" id="address" placeholder="请输入链接地址,例:http://www.baidu.com" />');
			$("#flag").val(1);
			$("#extIds").val(id);
			$("#types").val(types);
			$("#dorecommendform").show();
		}
		if(add_flag==2){
			$("#addsure").text("取消上架");
			$("#showname").text("取消原因");
			var str = "<input type='radio' name='reason'  value='1'>商品涉及侵权<br/>";
			str+="<input type='radio' name='reason'  value='2'>商品成本过高<br/>";
			str+="<input type='radio' name='reason'  value='3' >其他原因&nbsp;&nbsp;";
			str+="<input type='text'  name='address' id='address' placeholder='请输入取消原因'/>";

			$("#settext").html(str);
			$("#flag").val(2);
			$("#extIds").val(id);
			$("#types").val(types);
			$("#dorecommendform").show();
		}
		if(add_flag ==3){
			var id = $("#extIds").val();
			var flag = $("#flag").val(); //1为商品上架，2为取消商品上架
			var address = $("#address").val();
			var types = $("#types").val();

			if(flag==1){
				if(!address){
					alert("链接地址不能为空"); return false;
				}
			}
			if(flag==2){
				var reason = document.getElementsByName('reason');
				for(var i=0;i<reason.length;i++){
					if(reason[i].checked==true){
						var reason_value = reason[i].value;
					}
				}
				if(reason_value==1){
					var address = "商品涉及侵权";
				}
				if(reason_value==2){
					var address = "商品成本过高";
				}
				if(reason_value==3){
					var address = $("#address").val();
					if(!address){
						alert("请填写取消原因");return false;
					}
				}
			}

			$.post("/welcome/ajaxbutton", {"op": "sureAddGoods","id":id,"address":address,"flag":flag,"types":types},
					function(data){
						if(data==200)
						{
							alert("成功!");
							window.location.reload();
						}else{
							alert("失败");return false;
						}
					},"text");
			//$("#dorecommendform").hide();
		}

	}
</script>
</body>
</html>